package cn.zdnf.daolmpl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import cn.zdnf.bean.Ec_shopcarInfo;
import cn.zdnf.dao.Ec_shopcarInfoDao;
import cn.zdnf.util.JDBCUtil;

public class Ec_shopcarInfoDaoImpl implements Ec_shopcarInfoDao {

	@Override
	public List<Ec_shopcarInfo> findCar(String usernamId) {
String sql ="select b.id,b.image,b.title,b.PRICE,b.DISCOUNT,a.buyNum,a.userId from ec_shopcar a inner join ec_article b on a.articleId=b.id where a.userId=?;";
String[] info = {usernamId};		

List<Ec_shopcarInfo> list= new ArrayList<>();
 ResultSet rs= JDBCUtil.executeQuery(sql, info);
try {
	while(rs.next()) {
		Ec_shopcarInfo shcarInfo =new Ec_shopcarInfo();
		shcarInfo.setId(rs.getString("id"));
		shcarInfo.setImage(rs.getString("image"));
		shcarInfo.setTitle(rs.getString("title"));
		shcarInfo.setPRICE(rs.getString("PRICE"));
		shcarInfo.setDISCOUNT(rs.getString("DISCOUNT"));
		shcarInfo.setBuyNum(rs.getString("buyNum"));
		shcarInfo.setUserId(rs.getString("userId"));
		
		
		
		System.out.println(shcarInfo);
	list.add(shcarInfo);
		
	}
} catch (SQLException e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
}


return list;
	}

	
	
}
